<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="stylesheet" href="../../css/style.css">
    <link rel="stylesheet" href="../../css/order.css">
    <title>待发货</title>
    <style>
    </style>
</head>
<body>

  <div class="configNav"></div>
    <!-- content -->
    <div class="container-fluid">
        <div class="row">
            <!-- left -->
            <div class="col-md-2">
                <div class="list-group">
                    <a href="order_index.html" class="list-group-item active">交易订单</a>
                    <a href="deliver_index.html" class="list-group-item ">发货</a>
                    <a href="address.html" class="list-group-item ">发货设置</a>
                    <a href="evaluate_admin.html" class="list-group-item ">评价管理</a>
                </div>
            </div>
            <!-- right -->
            <div class="col-md-10">
                <ol class="breadcrumb">
                    <li><a href="">商家管理中心</a></li>
                    <li><a href="">订单物流</a></li>
                    <li class="active"><a href="">交易订单</a></li>
                </ol>
               <ul class="nav nav-tabs" >
                <li ><a href="order_index.html">所有订单  </a></li>
                <li><a href="order_waitPay.html">待付款</a></li>
                <li class="chose"><a href="order_waitSend.html">待发货</a></li>
                <li><a href="order_alreadySend.html">已发货</a></li>
                <li><a href="order_success.html">已完成</a></li>
                <li><a href="order_cancel.html">已取消</a></li>
               </ul>
               <div id="search">
                <form class="form-inline col-md-10" >
                <div class="form-group">
                    <label for="">下单时间</label>
                    <div class="input-group date form_date_str" id="startTime" data-date="" data-date-format="dd MM yyyy"  data-link-format="yyyy-mm-dd">
                        <input class="sreenMedia"  type="text" value="" readonly>
                        <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
                    </div>
                    -
                    <div class="input-group date  form_date_end" id="endTime" data-date="" data-date-format="dd MM yyyy"  data-link-format="yyyy-mm-dd">
                        <input  class="sreenMedia" type="text" value="" readonly>
                        <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
                    </div>
                    <label>买家
                    <input class="sreenMedia" type="text" id="searchBuyerName">
                    </label>
                    <label>订单编号
                    <input class="sreenMedia" type="text" id="searchOrderSn">
                    </label>
                    支付方式
                    <select id="paymentCode">
                            <option value="">全部</option>
                            <option value="1">支付宝支付</option>
                            <option value="2">金券支付</option>
                            <option value="3">物券支付</option>
                            <option value="4">银行卡支付</option>
                            <option value="5">微信支付</option>
                    </select>
                </div>
            </form>
            <button style="width:70px;" class="searchBtn">搜索</button>
       </div>
                    <!--<div class="nav nav-tabs">
                    <a class="btn btn-primary active allorder" href="javascript:;" role="button" ><i class="glyphicon glyphicon-search"></i>全部订单</a>
                 <a class="btn btn-primary" href="javascript:;" role="button"><i class="glyphicon glyphicon-search"></i>普通用户订单</a>
                    <a class="btn btn-primary" href="javascript:;" role="button"><i class="glyphicon glyphicon-search"></i>企业用户订单</a> 
                </div>-->
            <table class="table table-bordered">
                    <thead >
                        <tr class="order-ti">
                           <th class="col-md-3">商品</th>
                            <th >单价</th>
                            <th >数量</th>
                            <th >买家</th>
                            <th class="col-md-2">订单金额</th>
                            <th class="col-md-2">交易状态</th>
                            <th class="col-md-2">交易操作</th>

                        </tr>
                    </thead>

                    <tbody id="orderList">  </tbody>
                </table>
                 <nav aria-label="...">
                    <div class="">
                      <span id="pageNum">共&nbsp;<strong></strong>&nbsp;页&nbsp;/&nbsp;</span><span id="totalNum">&nbsp;<strong>0</strong>&nbsp;条数据</span>
                    </div>
                    <ul id="example"></ul>
                  </nav>
            </div>
        </div>
    </div>
    <script src="../../js/jquery.min.js" charset="utf-8"></script>
    <script src="../../js/bootstrap.min.js" charset="utf-8"></script>
     <script src="../../plugin/layer/layer.js" charset="utf-8"></script>
    <script src="../../plugin/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js" charset="utf-8"></script>
    <script src="../../plugin/bootstrap-datetimepicker/js/bootstrap-datetimepicker.zh-CN.js" charset="utf-8"></script>
    <script src="../../plugin/wangEditor/release/wangEditor.min.js" charset="utf-8"></script>
    <script src="../../js/nav.js" charset="utf-8"></script>
    <script src="../../js/common.js" charset="utf-8"></script>
    <script src="../../js/bootstrap-paginator.js" charset="utf-8"></script>
    <script src="../../js/ajax.js" charset="utf-8"></script>
    <script type="text/javascript">
      //时间
	      $(".form_date_str").datetimepicker({
	    　    minView: "month", 
	        　format: "yyyy-mm-dd", 
	        　language: 'zh-CN', 
	        　autoclose:true 
	        });
	        $(".form_date_end").datetimepicker({
	        　minView: "month", 
	        　format: "yyyy-mm-dd", 
	        　language: 'zh-CN',
	        　autoclose:true 
	        });
        $(document).ready(function(){
                tableList()
            });
        //查询商家订单列表
        var pageUrls = cncbk_common_tools.serverURL + '/business/order/queryOrderList';
        function tableList(){
            //分页
            data = {
                'storeId':24,
                'page':page,
                'orderStatus':2,
                'pageSize':pagesize
            }
            data.page = 1
            ajax(
                pageUrls,
                data,
                pageNumList,
                'post',
                'json'
            )
        }
//      //全部订单
//      $('.allorder').off('.click').on('click',function(){
//          tableList()
//      })
        //数据渲染
        function OpendList(res){
            $('#orderList').empty();
            var html='';
            for (var i = 0; i < res.data.list.length; i++) {
                var noShow = '';
                if(Number(res.data.list[i].orderStatus)==7){
                    noShow = 'noShow';
                }
                var orderDetailId = res.data.list[i].orderDetailId;
                  var goodsPrice = res.data.list[i].goodsPrice;
                var isSpe = res.data.list[i].isSpe;
                	var nuit='';
                	if (isSpe == 1){
                		nuit='券';
                		goodsPriceUnit='<span>' + goodsPrice + nuit + '</span>';
                	}if (isSpe ==0) {
                		nuit='元';
                		goodsPriceUnit='<span>' + goodsPrice + nuit + '</span>';
                	}
               html += '<tr class="'+noShow+'">'+
                '<th colspan="7" class="thli">'+
                '<ul>'+
                '<li class="orderDetailId" orderDetailId="'+orderDetailId+'">订单编号：<span>'+res.data.list[i].orderSn+'</span><span><i class="glyphicon glyphicon-phone"></i></span></li>'+
                '<li>下单时间：<span>'+res.data.list[i].orderTime+'</span></li>'+
                '<li style="float:right;">'+
                '<button type="submit" class="orderPrint" orderDetailId="'+orderDetailId+'" style="margin:5px;"><i class="glyphicon glyphicon-print"></i>打印发货单</button>'+
                '</li>'+
                '</ul>'+
                '</th>'+
                '</tr>'+
                '<tr class="'+noShow+'">'+
                '<td class="thli col-md-3">'+
                '<ul class="goods">'+
                '<li class="goodsimg"><img src="http://axyhpic.oss-cn-zhangjiakou.aliyuncs.com/'+res.data.list[i].goodsImage+'" alt=""></li>'+
                '<li class="goodsName"><a href="">'+res.data.list[i].goodsName+'</a></li>'+
                '</ul>'+
                '</td>'+
                '<td><span>'+res.data.list[i].goodsPrice+'</span></td>'+
                '<td><span>'+res.data.list[i].goodsQuantity+'</span></td>'+
                '<td class="memberInfo" ><span>'+res.data.list[i].memberName+'</span>'+
                '<div class="suspendMain">'+
                    '</div>'+
                '</td>'+

                '<td >'+
                '<ul>'+
                '<li><span style="color:#f00;">'+res.data.list[i].goodsAmount+'元</span></li>'+
                '<li><span style="color:#f00;">'+res.data.list[i].isSpe +'券</span></li>'+
                '<li><span class="goodsFreight">运费:￥'+res.data.list[i].goodsFreight+'元</span></li>'+
                '<li><span>'+res.data.list[i].paymentCode+'</span></li>'+
                '</ul>'+
                '</td>'+
                '<td>'+
                '<span class="orderStatus">'+res.data.list[i].orderStatus+'</span><br>'+
                '<span ><a href="order_detail.html?orderDetailId='+orderDetailId+'"  class="orderDteails">订单详情</a></span>'+

                '</td>'+
                '<td>'+
                    '<button class="btn-revise jump"  orderDetailId="'+orderDetailId+'"> <i class="glyphicon glyphicon-plane"></i>设置发货</button>'+
                '</td>'+
                '</tr>';

            }

            $('#orderList').append(html);


            //订单状态显示
            $.each($('.orderStatus'),function(){
                console.log(Number($(this).text()))

                switch(Number($(this).text())){
                    case 1:
                    $(this).text('待付款');
                    break;
                    case 2:
                    $(this).text('待发货');
                    break;
                    case 3:
                    $(this).text('已发货');
                    break;
                    case 4:
                    $(this).text('已收货');
                    break;
                    case 5:
                    $(this).text('待评价');
                    break;
                    case 6:
                    $(this).text('已评价');
                    break;
                    case 7:
                    $(this).text('已取消');
                    break;
                    case 8:
                    $(this).text('退款');
                    break;
                    case 9:
                    $(this).text('拒收');
                    break;
                    case 10:
                    $(this).text('延迟收货');
                    break;
                }
            })

           //取消订单
            $('.removeOrder').click(function(){
                //获取订单明细id、取消原因id
                var pageUrls =cncbk_common_tools.serverURL +'/business/order/queryOrderList';
                var orderDetailId = $(this).attr('orderDetailId');

                data ={
                    'orderDetailId':orderDetailId,
                    // 'cancelReason':cancelReason
                }
                var func = function (res){
                    console.log(res)
                }
                console.log(orderDetailId)
                ajax(
                    pageUrls,
                    data,
                    func,
                    'post',
                    'json'
                )
            })

            //
            $('#other').click(function(){
                $('#otherReasonDesc').show();
            })
            //点击保存确定取消订单
            $('#yesCancel').click(function(){
                var pageUrls =cncbk_common_tools.serverURL +'/business/order/updateCalcelOrder';
                var orderDetailId = $('.orderDetailId').attr('orderDetailId');//获得订单id
                var cancelReason = $('[name="reason"]').val();
                var otherReasonDesc = $('#otherReasonDesc').val();
                data ={
                    'orderDetailId':orderDetailId,
                    'cancelReason':cancelReason,
                    'otherReasonDesc':otherReasonDesc
                }
                var func = function (res){
                   if(res.code==200){
                       $('.close').click();
                       tableList()
                   }else{
                    $('.close').click();
                   }
                }
                console.log(orderDetailId)
                ajax(
                    pageUrls,
                    data,
                    func,
                    'post',
                    'json'
                )
            })
            //搜索
            $('.searchBtn').click(function(){

                var pageUrls =cncbk_common_tools.serverURL + '/business/order/queryOrderList';
                var startTime = $('#startTime').val();
                var endTime = $('#endTime').val();
                var buyerName = $('#searchBuyerName').val();
                var orderSn = $('#searchOrderSn').val();
                var paymentCode=$('#paymentCode').val();
                console.log(paymentCode)
                data={
                    'startTime':startTime,
                    'endTime':endTime,
                    'buyerName':buyerName,
                    'orderSn':orderSn,
                    'paymentCode':paymentCode,
                    'page':1,
                    'pageSize':10
                }
                ajax(
                    pageUrls,
                    data,
                    pageNumList,
                    'post',
                    'json'
                )
            })

//          // 买家信息
//
//          $('.memberInfo').mouseenter(function(event){
//             $('.suspendMain').empty();
//              var pageUrls =cncbk_common_tools.serverURL + '/business/order/orderDetail';
//              var orderDetailId = $('.orderDetailId').attr('orderDetailId');//订单明细id
//              data = {
//                  'orderDetailId':orderDetailId,
//              }
//              var func = function (res){
//                  var html='';
//                  html += '<div class="suapend">'+
//                      '<div class="suspendContent">'+
//                      '<h5>联系信息</h5>'+
//                      '<ul>'+
//                      '<li><span>姓名：'+res.data.orderReciver.name+'</span></li>'+
//                      '<li><span>电话：'+res.data.orderReciver.phone+'</span></li>'+
//                      '<li><span>地址：'+res.data.orderReciver.addressName+res.data.orderReciver.address+'</span></li>'+
//                      '</ul>'+
//                      '</div>'+
//                      '</div>';
//                  $('.suspendMain').append(html);
//                  $('.suapend').show();
//                  $('.suapend').mouseenter(function(event){
//                      event.stopPropagation();
//                  })
//
//                  }
//
//              ajax(
//                  pageUrls,
//                  data,
//                  func,
//                  'post',
//                  'json'
//
//              )
//
//          }).mouseleave(function(){
//              $('.suapend').hide();
//          })

            //打印发货单跳转
            $('.orderPrint').click(function(){
                window.location.href = "order_print.html?orderDetailId="+ $(this).attr('orderDetailId');
            })
              //设置发货跳转
              $('.jump').click(function(){
                window.location.href = "deliver_set.html?orderDetailId="+ $(this).attr('orderDetailId');
            })

        }
    </script>
</body>
</html>
